const tencentcloud = require('tencentcloud-sdk-nodejs');

function imgtest(url) {
	const ImsClient = tencentcloud.ims.v20200713.Client;
	const clientConfig = {
		credential: {
			secretId: 'AKIDoOjc1LD5ZooY2KsItEKL7as1vZy8ooRn',
			secretKey: 'AA1XszqX0FF0bCXcYFiwuiJkqlUt26ua'
		},
		region: 'ap-beijing',
		profile: {
			// httpProfile: {
			// 	endpoint: 'tms.tencentcloudapi.com'
			// },
			signMethod: 'HmacSHA256', // 签名方法
			httpProfile: {
				reqMethod: 'POST', // 请求方法
				reqTimeout: 30 // 请求超时时间，默认60s
			}
		}
	};
	const IMGclient = new ImsClient(clientConfig);
	const params = {
		// FileUrl: 'https://imgs.ruiyanghj.com/user_upload/a-debug-0-20201124114239.png'
		FileUrl: url
	};
	let re = IMGclient.ImageModeration(params).then(
		data => {
			console.log(data);
			return Promise.resolve(data.Suggestion);
		},
		err => {
			console.error('error', err);
			return Promise.reject(err);
		}
	);
	return re;
}
export default { //通过default导出，可以一次性导入
	imgtest,
}
